package com.iss.demo.dao;

import com.iss.demo.entity.ggCourse;
import com.iss.demo.model.ggCourseModel;
import com.iss.demo.model.ggCourseModel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ggCourseDao {


        @Select("select * from gg_course inner join coursetype on gg_typeid=t_id")
        List<ggCourseModel> selectAll();


        @Delete(" <script>"+"delete from gg_course where gg_id in" +
                "    <foreach collection=\"array\" item=\"id\" separator=\",\" open=\"(\" close=\")\">" +
                "        #{id}" +
                "    </foreach></script>")
        public Integer delete(Integer[] gg_ids);
//    @Delete("delete from gg_course where gg_id=#{gg_id}")
//    public Integer deleteOne(Integer gg_id);

        @Insert("insert into gg_course values(null,#{gg_name},#{gg_time},#{gg_price},#{gg_des},#{gg_typeid},null,null)")
        public Integer insertCourse(ggCourse ggcourse);

        @Update("update gg_course set gg_name=#{gg_name},gg_time=#{gg_time},gg_price=#{gg_price},gg_des=#{gg_des},gg_typeid=#{gg_typeid} where gg_id=#{gg_id}")
        public Integer updateCourse(ggCourse ggcourse);

        @Select("select * from gg_course where gg_id=#{gg_id}")
        public ggCourse selectByid(Integer id);

        @Select("select gg_name,gg_price from gg_course where gg_id=#{gg_id}")
        public ggCourse shopcar(Integer id);

        @Update("update gg_course set gg_surface = #{surface},gg_info = #{info} where gg_id=#{id}")
        public Integer updateInfo(@Param("surface") String surface,@Param("info") String info,@Param("id") Integer id);

        @Select("select * from gg_course inner join coursetype on gg_typeid=t_id where gg_id=#{gg_id}")
        public ggCourseModel selectInfoById(Integer gg_id);
    }